//
//  String+Extension.swift
//  TDDStudySwift
//
//  Created by baidu on 6/28/16.
//  Copyright © 2016 caoyuan. All rights reserved.
//

import Foundation

extension String {
    
    subscript (r: Range<Int>) -> String {
        get {
            let startIndex = self.characters.index(self.startIndex, offsetBy: r.lowerBound)
            let endIndex = self.characters.index(self.startIndex, offsetBy: r.upperBound)
            return self[startIndex..<endIndex]
        }
    }
    subscript (index: Int) -> String {
        get {
            return self[index..<index + 1]
        }
    }
    func pySplit(str:Character) -> [String] {
        let stra = self.characters.split(separator: str).map { (String($0)) }
        return stra
    }
    
    // find character from str, if find it return index, else return -1
    func  pyFind(str:Character) -> Int {
        return -1
    }
}
